/**
 * Create on 2010-4-22 04:13:06
 * @author JIXF
 * @E-Mail:jixf@mochasoft.com.cn
 */

package com.lq.util;

import java.util.Map;
import java.util.Properties;

/**
 * <a href="SystemProperties.java.html"><b><i>View Source</i></b></a>
 *
 * @author  JIXF
 *
 */
public class SystemProperties {

	public static final String SYSTEM_PROPERTIES_LOAD = "system.properties.load";

	public static final String SYSTEM_PROPERTIES_FINAL = "system.properties.final";

	public static final String TMP_DIR = "java.io.tmpdir";

	public static String get(String key) {
		String value = (String) _instance._props.get(key);

		if (value == null) {
			value = System.getProperty(key);
		}

		return value;
	}

	public static void set(String key, String value) {
		_instance._props.put(key, value);
	}

	public static String[] getArray(String key) {
		String value = get(key);

		if (value == null) {
			return new String[0];
		} else {
			return StringUtil.split(value);
		}
	}

	public static Properties getProperties() {
		return PropertiesUtil.fromMap(_instance._props);
	}

	private SystemProperties() {
	}

	private static SystemProperties _instance = new SystemProperties();

	private Map _props;
}